package com.example.ucs.interceptor;

import com.example.ucs.prop.AuthProp;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Bean
    public GlobalApiInterceptor globalApiInterceptor() {
        return new GlobalApiInterceptor();
    }



    @Bean
    RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Resource
    private AuthProp authProp;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(globalApiInterceptor())
                .addPathPatterns(authProp.getInterceptPathList())
                .excludePathPatterns(authProp.getExcludePathList());
    }


//————————————————
//    版权声明：本文为CSDN博主「shua_shua」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//    原文链接：https://blog.csdn.net/shua_shua/article/details/105489302
}
